﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace QMERP.Infrastructure.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class init10 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "RetailOrderDetail_SalesProcess");

            migrationBuilder.CreateTable(
                name: "RetailOrder_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RetailOrderId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RetailOrder_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RetailOrder_SalesProcess_RetailOrder_RetailOrderId",
                        column: x => x.RetailOrderId,
                        principalTable: "RetailOrder",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RetailOrder_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_SalesProcess_Id",
                table: "RetailOrder_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_SalesProcess_RetailOrderId",
                table: "RetailOrder_SalesProcess",
                column: "RetailOrderId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrder_SalesProcess_SalesProcessId",
                table: "RetailOrder_SalesProcess",
                column: "SalesProcessId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "RetailOrder_SalesProcess");

            migrationBuilder.CreateTable(
                name: "RetailOrderDetail_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RetailOrderDetailId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RetailOrderDetail_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_SalesProcess_RetailOrderDetail_RetailOrderDetailId",
                        column: x => x.RetailOrderDetailId,
                        principalTable: "RetailOrderDetail",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RetailOrderDetail_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_SalesProcess_Id",
                table: "RetailOrderDetail_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_SalesProcess_RetailOrderDetailId",
                table: "RetailOrderDetail_SalesProcess",
                column: "RetailOrderDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_RetailOrderDetail_SalesProcess_SalesProcessId",
                table: "RetailOrderDetail_SalesProcess",
                column: "SalesProcessId");
        }
    }
}
